<%@page import="com.mxbbx.wdn.domain.menu.Menu"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/base.jsp"%>


<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">

<title>用户列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/admin.css">
<script src="js/jquery-1.4.4.min.js"></script>
<script src="js/admin.js"></script>
<script type="text/javascript">
	function searchUser(userId,userForm){
		var search = document.getElementById(userId).value; 
		//判断输入的查询条件是否为空
		if(search==""){
			alert("请输入查询条件");
		}
		else{
			document.getElementById(userForm).submit();
		}
	}
</script>
</head>

<body>
	<form method="post" action="page/user/searchUser_list.jsp" id="userForm">
	<div class="panel admin-panel">
		<div class="panel-head">
			<strong class="icon-reorder"> 用户信息列表</strong>
		</div>
		<div class="padding border-bottom">
			<ul class="search" style="padding-left:10px;">
				<li><a class="button border-main icon-plus-square-o"
					href="<%=path%>/system/UserServlet?m=input"> 添加用户</a></li>
				 <li>搜索：</li>
        <li>
        <input type="text" placeholder="请输入搜索关键字" name="userId" class="input" style="width:250px; line-height:17px;display:inline-block" id="userId"/>
          <a href="javascript:void(0)" class="button border-main icon-search" onclick="searchUser('userId','userForm')" > 搜索</a>
          </li>
			</ul>
		</div>
		<table class="table table-hover text-center">
			<tr>
			<th width="50" style="text-align:center;">&nbsp;</th>
				<th width="50">序号</th>	
				<th>用户编号</th>
				<th>姓名</th>		
				<th>状态</th>
				<th>所在部门</th>
				<th>操作</th>
			</tr>

			<%
					String pageNo = request.getParameter("pageNo");
					int p = pageNo == null ? 1 : Integer.parseInt(pageNo);
					UserDao userDao = new UserDao();
					String sql = "select * from user where 1=1 ";
					Object[] params = {};
					Page pageBean = userDao.queryOjectsByPage(sql, params, p,
							Constant.ROW);
				%>
				<%
					for (int i = 0; i < pageBean.getDatas().size(); i++) {

						User model = (User) pageBean.getDatas().get(i);
				%>

			<tr>
			<td><input type="checkbox" name="ids"
						value="<%=model.getUserId()%>" /></td>
					<td><%=(i+1) %></td>
					<td><%=model.getUserId()%></td>
					<td><%=model.getFullName()%></td>
					 <td><%="1".equals(model.getStatus())?"正常":"禁用" %></td>
					 <td><%=model.getAgencode()%></td>
					<td><div class="button-group">
							<a class="button border-main"
								href="<%=path%>/system/UserServlet?m=get&id=<%=model.getUserId()%>"><span
								class="icon-edit"></span> 修改</a> <a class="button border-red"
								href="<%=path%>/system/UserServlet?m=del&id=<%=model.getUserId()%>"><span
								class="icon-trash-o"></span> 删除</a>
						</div></td>
				</tr>
			<%
				}
			%>
		
    </table>
    
 <div class="pagelist">
				<%
					if (pageBean.hasPre()) {
				%>
				<a
					href="<%=path%>/system/UserServlet?m=list&pageNo=<%=pageBean.prePage()%>">上一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">上一页</a>
				<%
					}
				%>
				<%
					List<Integer> linkNums = pageBean.linkLumbers();
					for (int num : linkNums) {
					if (pageBean.isCurrent(num)) {
				%>
				<span class="current"><%=num%></span>
				<%
					} else {
				%>
				<a href="<%=path%>/system/UserServlet?m=list&pageNo=<%=num%>"><%=num%></a>
				<%
					}
					}
				%>
				<%
					if (pageBean.hasNext()) {
				%>
				<a
					href="<%=path%>/system/UserServlet?m=list&pageNo=<%=pageBean.lastPage()%>">下一页</a>
				<%
					} else {
				%>
				<a href="javascript:void(0)">下一页</a>
				<%
					}
				%>
				<a
					href="<%=path%>/system/UserServlet?m=list&pageNo=<%=pageBean.getPages()%>">尾页</a>
			</div>
		</form>
    </div>
</body>
</html>
